<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
|   example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
|   http://codeigniter.com/user_guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There are two reserved routes (three in CI3):
|
|   $route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
|   $route['404_override'] = 'errors/page_missing';
|
| This route will tell the Router which controller/method to use if those
| provided in the URL cannot be matched to a valid route.
|
| CI3:
|
|   $route['translate_uri_dashes'] = FALSE;
|
| This is not exactly a route, but allows you to automatically route
| controller and method names that contain dashes. '-' isn't a valid
| class or method name character, so it requires translation.
| When you set this option to TRUE, it will replace ALL dashes in the
| controller and method URI segments.
|
| Examples: my-controller/index -> my_controller/index
|       my-controller/my-method -> my_controller/my_method
*/

// $route['default_controller'] = $this->uri->uri_string()==SITE_AREA ? 'home' : 'buildings/front/buildingHome/indexFour';//'buildings/front/home';//'home';
$route['default_controller'] = $this->uri->uri_string()==SITE_AREA ? 'home' : 'buildings/front/buildingHome';//'buildings/front/home';//'home';

if (!is_cli()) {
    $serverName = $_SERVER['HTTP_HOST'];
    if (stripos($serverName, 'fang90.com') !== false) {
        $route['default_controller'] = 'buildings/front/home';
    }else if(stripos($serverName, 'plus-fang.com') !== false){
        $route['default_controller'] = 'buildings/front/home/fangPlus';
        Route::get('fang/(\w+)', 'buildings/front/home/fangPlusList/$1');
    }else if(stripos($serverName, 'www.pinxiaochina.cn') !== false){
        $route['default_controller'] = 'buildings/front/home/pinxiaochina';
    }
}
$route['404_override'] = '';
// Authentication
Route::any(LOGIN_URL, 'users/login', array('as' => 'login'));
Route::any(REGISTER_URL, 'users/register', array('as' => 'register'));
Route::block('users/login');
Route::block('users/register');

Route::any('logout', 'users/logout');
Route::any('forgot_password', 'users/forgot_password');
Route::any('reset_password/(:any)/(:any)', 'users/reset_password/$1/$2');

// Activation
Route::any('activate', 'users/activate');
Route::any('activate/(:any)', 'users/activate/$1');
Route::any('resend_activation', 'users/resend_activation');

Route::get('building', 'buildings/front/building');
Route::get('building/(\d+)', 'buildings/front/building/detail/sh/$1');
Route::get('about', 'buildings/front/home/about');
Route::get('companypx', 'buildings/front/home/companypx');
Route::get('contactpx', 'buildings/front/home/contactpx');
Route::get('productpx', 'buildings/front/home/productpx');
Route::get('privacy', 'buildings/front/home/privacy');
Route::get('building/(\w+)/(\d+)/campaign', 'buildings/front/building/detail/$1/$2');
// Route::get('building/(\w+)/(\d+)', 'buildings/front/building/detail/$1/$2');
Route::get('building/(\w+)/(\d+)', 'buildings/front/buildinginfo/info/$1/$2');
// Route::get('building/(\w+)', 'buildings/front/home/index/$1/1');
Route::get('building/(\w+)', 'buildings/front/buildingList/index/$1');
Route::get('buildinglist/(\w+)', 'buildings/front/buildingMobileList/index/$1');

Route::get('news/(\w+)/(\d+)', 'buildings/front/home/newsdetail/$1/$2');
Route::get('post/(\w+)/campaign', 'buildings/front/home/postdetail/$1/campaign');
Route::get('topic/(\w+)', 'buildings/front/home/topicDetail/$1');
Route::get('topictest/(\w+)', 'buildings/front/home/topicTest/$1');
Route::get('topictest/(\w+)/(\w+)', 'buildings/front/home/topicTest/$1/$2');
Route::get('topictest/wechatOauthBack', 'buildings/front/home/wechatOauthBack');
//活动专用路由
Route::prefix('activity', function(){
    Route::get('fangjinsuo', 'activity/fangjinsuo');
    Route::get('server', 'activity/server');
    Route::get('jinrong/(\w+)', 'activity/jinrong/$1');
});
// 魔盒
Route::prefix('mohe', function(){
    $mohe = 'mohe/front/mohe';
    Route::get('preview', $mohe.'/preview');
    // Route::get('preview', 'mohe/front/building/detail');
    Route::get('building/(\d+)/campaign', 'mohe/front/building/detail/shanghai/$1');
    Route::get('account', $mohe.'/account');
    Route::get('media', $mohe.'/media');
    Route::get('media_order', $mohe.'/mediaOrder');
    Route::get('phone', $mohe.'/phone');
    Route::get('produce', $mohe.'/produce');
    Route::get('report', $mohe.'/report');
    Route::get('template', $mohe.'/template');
    Route::get('charge', $mohe.'/charge');
    Route::get('banner', $mohe.'/banner');
    Route::get('charge_log', $mohe.'/chargeLog');
    Route::get('charge_detail', $mohe.'/chargeDetail');
    Route::any('wechatOauthBack', $mohe.'/wechatOauthBack');
    Route::any('taocan', $mohe.'/taocan');
    Route::get('chargetest', $mohe.'/chargeTest');
    Route::post('wxpay', $mohe.'/wxPay');
    Route::post('testpay', $mohe.'/wxPay');
    Route::any('notice', $mohe.'/notice');
    Route::any('about', $mohe.'/about');
    Route::any('zhaoke', $mohe.'/zhaoke');
    
});

// Route::get('building/info/(\w+)/(\d+)', 'buildings/front/buildinginfo/info/$1/$2');
// Contexts
Route::get(SITE_AREA, 'admin/home/index');
Route::prefix(SITE_AREA, function(){
    // Route::context('content', array('home' => SITE_AREA .'/content/index'));
    // Route::context('reports', array('home' => SITE_AREA .'/reports/index'));
    Route::context('content', array('home' => 'admin/content/index'));
    Route::context('reports', array('home' => 'admin/reports/index'));
    Route::context('update', array('home' => 'admin/update/index'));
    Route::context('black', array('home' => 'admin/black/index'));
    Route::context('activity', array('home' => 'admin/activity/activity'));
    Route::context('developer');
    Route::context('settings');
    Route::context('building');
    Route::context('schoolhouse');
    Route::context('tgsz');
    Route::context('home');
    Route::context('report');
    Route::context('passage');
    Route::context('campaign');
    Route::context('lingxi');
    Route::context('subject');

    Route::any(LOGIN_URL, 'users/staff/login');
    Route::any('logout', 'users/staff/logout');
});

$route = Route::map($route);

if (defined(CI_VERSION) && substr(CI_VERSION, 0, 1) != '2') {
    $route['translate_uri_dashes'] = false;
}
